﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace myMapObj
{
    /// <summary>
    /// 部分类
    /// </summary>
    public class moParts
    {
        #region 字段
        private List<moPoints> _Parts;
        #endregion

        #region 构造函数
        public moParts()
        {
            _Parts = new List<moPoints>();
        }
        public moParts(moPoints[] parts)
        {
            _Parts = new List<moPoints>();
            _Parts.AddRange(parts);
        }
        #endregion

        #region 属性
        public Int32 Count
        {
            get { return _Parts.Count; }
        }
        #endregion

        #region 方法

        /// <summary>
        /// 获取指定索引号的元素
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public moPoints GetItem(Int32 index)
        {
            return _Parts[index];
        }

        /// <summary>
        /// 设置指定索引号的元素
        /// </summary>
        /// <param name="index"></param>
        /// <param name="part"></param>

        public void setItem(Int32 index, moPoints part)
        {
            _Parts[index] = part;
        }

        /// <summary>
        /// 添加元素
        /// </summary>
        /// <param name="part"></param>
        public void Add(moPoints part)
        {
            _Parts.Add(part);
        }

        /// <summary>
        /// 添加数组中的所有元素
        /// </summary>
        /// <param name="parts"></param>
        public void AddRange(moPoints[] parts)
        {
            _Parts.AddRange(parts);
        }

        /// <summary>
        /// 将元素插入指定索引位置
        /// </summary>
        /// <param name="index"></param>
        /// <param name="part"></param>
        public void Insert(Int32 index,moPoints part)
        {
            _Parts.Insert(index, part);
        }

        /// <summary>
        /// 将数组插入指定索引位置
        /// </summary>
        /// <param name="index"></param>
        /// <param name="parts"></param>
        public void InsertRange(Int32 index,moPoints[] parts)
        {
            _Parts.InsertRange(index, parts);
        }

        /// <summary>
        /// 删除指定索引处的元素
        /// </summary>
        /// <param name="index"></param>
        public void RemoveAt(Int32 index)
        {
            _Parts.RemoveAt(index);
        }

        /// <summary>
        /// 清除
        /// </summary>
        public void Clear()
        {
            _Parts.Clear();
        }

        /// <summary>
        /// 克隆
        /// </summary>
        /// <returns></returns>
        public moParts Clone()
        {
            moParts sParts = new moParts();
            Int32 sPartCount = _Parts.Count;
            for (Int32 i = 0; i <= sPartCount - 1; i++)
            {
                moPoints sPart = _Parts[i].Clone();
                sParts.Add(sPart);
            }
            return sParts;
        }
        #endregion
    }
}
